package com.mgr.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mgr.model.Accounts;
import com.mgr.model.Customers;
import com.mgr.service.AccountService;
import com.mgr.service.CustomerService;

@Controller
public class ViewProfileController {
	@Autowired
	private CustomerService customerService;
	@Autowired
	private AccountService accountService;

	@RequestMapping("view_account_profile")
	public String viewProfile(HttpSession session, Map<String, Object> map) {
		String result = "viewProfileCustomer.tile";
		String user = (String) session.getAttribute("user");
		if (user == null || user == "") {
			result = "login";
		} else {
			Customers customer = customerService.getCustomers(Integer
					.parseInt(user));
			map.put("cust", customer);
			List<Accounts> listAcc = accountService.getAccountByCustId(Integer
					.parseInt(user));
			map.put("accountList", listAcc);
		}

		return result;
	}
	
}